using UnityEngine;
using System.Collections;

public class shockwaveScript: MonoBehaviour {
	public float life = 0.0f;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		life += Time.deltaTime;
		if(life > 0.75f){
			GameObject.Destroy(gameObject);
		}
	}
	void OnTriggerEnter(Collider other){
		PlayerScript p = other.GetComponent<PlayerScript>();
		if(p != null){
			Vector3 kd = new Vector3(0,0,0);
			if(other.transform.position.x > transform.position.x){
				kd.x = 1;
			}
			else if(other.transform.position.x == transform.position.x){
				kd.x = 0;
			}
			else{
				kd.x = -1;
			}
			if(other.transform.position.z > transform.position.z){
				kd.z = 1;
			}
			else if(other.transform.position.z == transform.position.z){
				kd.z = 0;
			}
			else{
				kd.z = -1;
			}
			p.setKnockback(kd);
		}
	}
}
